package com.service.xsxt;

import com.dao.xsxt.TestMapper;
import com.entity.common.ApiResult;
import com.entity.xsxt.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by System on 2019/03/19 11:44:00.
 */
@Service
public class TestService {

    @Autowired
    private TestMapper testMapper;

    public List<Test> getPageList(Test test){
        return testMapper.getPageList(test);
    }

    public ApiResult addTest(Test test) {
        int num = testMapper.insertSelective(test);
        return  new ApiResult(num);
    }

    public ApiResult getTestById(Integer id) {
        Test test = testMapper.selectByPrimaryKey(id);
        return new ApiResult(true,"获取数据成功！",test);
    }

    public ApiResult editTest(Test test) {
        int num = testMapper.updateByPrimaryKeySelective(test);
        return  new ApiResult(num);
    }

    public ApiResult deleteTest(int id) {
        int num = testMapper.deleteByPrimaryKey(id);
        return  new ApiResult(num);
    }
}
